refactored mouse control into a separate class