Refactored Pan Gesture Code and fixed image movement