making code more readable, added line tool and  common function for touch and mouse event