working version with manual gesture detection