refactoring of touch handling