refactored code and added swipe recognizer