Added new check for enabling undo button