fix crash when pressing cancel