sanitized the cancel button behavior