added undo and redo history and reformated rest of code to cope with that