Updated buildSwipe function