In the war of Mahabharata, when Arjun asked Lord Krishna how to control the mind? Then Krishna replied that it could be won with two weapons—"abhyasa" and "detachment". When the mind wanders, bring it back to the goal and distance yourself from the pleasures that distract the mind.