This happens with me also, but to a lesser extent I guess. Here are a few things which helped me.
Stick pictures of what you really want (like a good rank as of now) near your study table. Looking at it will inspire you to work more. Try to have control on your thoughts(though its really hard but you can atleast minimize unnecessary thoughts)
At the end of the day It's only you who can help yourself to become better.
Hope this helps!