state machine implementation for gestures