got undo feature working, still has some bugs though.