Added do/undo functions using stack