Swipe and partial undo added to this code

I added the swipe by changing some functions in the code.