UndoStack improvement

Instead of checking for -1, check the returned bool variable.