refactored swipe event handler to a method