Refactored function touchRock