There are many ways to avoid all the unnecessary distractions like going to a quiet place to work, a library, or an empty room, even those places where distractions are highly inaccessible, using apps to block your distracting sites. There are also other ways which you can use, whichever is best suited for you will always work best, and you can look on the internet or can ask friends about it.