Gesture code refactoring