First of all, remove all myths & misconceptions from your mind about masturbation
In fact, Masturbation is completely normal & doesn't have any bad effect to the body and mind unless you get addicted to it.
Since you are feeling that your masturbation is interfering with your normal functioning, you can try out the following measures:
1. Improve your social life by spending more time with friends and relatives.
2. Keep your mind active and busy at all times either through curricular or extra-curricular activities.
3. Have a diet rich in fruits, vegetables, fish, nuts & honey.
4. Avoid fast foods & lipid containing diet.
5. Avoid smoking
6. Keep away stress
, think positive.
7. Exercise regularly & practice meditation
These measures will be helpful in improving concentration & builds up the confidence level.