corrected the flipped coordinates and made the mouse control independent from global position