fixing the bug with Cancel button