solving mouse exiting bug