added gesture detection
refactored