added the logic for swiping pages