fixing swipe and make code cleaner