refactoring: separated click detection and processing