Refactoring calculating angle
Refactoring detect eventType
Fix event handling