Bugfix with undoing