As Lester Burnham (age 42) said in American Beauty (1999), one of my top 5 Desert Island Films "It's never too late to get it back".
My best period has been age 40 to date. MUCH better than 35 to 40. Slightly better than 26-34 (my prime years physically, but lacking the financial resources and dating experience).
However, something fundamental must change to make a major improvement. It has to come through healthy living, and gradually.
It should start with diet. In fact, it should start with a rigorous fast. Can you go 1 day without consuming anything but water, herbal tea, medicinal herbs (and maybe some vaporized weed)? No alcohol, tobacco, coffee or prescription drugs. Then, start bicycling and doing push-ups and chin-ups.
Then, you will need practice. Pay a few escorts for dates and/or sex. Ask them for suggestions. At age 40, to really correct the problem, go straight to the source and ask women (but don't expect the particular women you ask to be interested). Sacrifice a few women to learn the truth.
As a backup plan, ask guys (pay them if needed) to ask the women the truth. Find out the truth and go from there. Everyone has flaws and our flaws are what make us more human and lovable so don't aim for perfection.