To stay motivated, create small goals building into big goals. Achieve the small goals and the big goals will be easy. Little steps must be taken and accomplished each day to build a new way of behaving for yourself.
When you started whatever habit you are trying to beat, you started it the same way. To change it, you have to start a new habit. One good for you instead of bad for you. Use small daily steps to change.