refactoring
improved mouse position handling