fixed record history functions
adding logic for undo method
added logic for undo feature