Excessive masturbation, use of pornography while masturbating, and unhealthy sexual hygiene all can risk you for development of ED. A detailed history regarding the problem is required. Associated history regarding use of pornography, lifestyle associated risk factors is required. You must also learn about healthy way of masturbating and about sexual hygiene.
Next Steps
I would suggest you to consult with a sexologist. For a detailed answer and advice you can consult with me directly here on practo.
Health Tips
Do not worry, it can be successfully overcomed.