handling submit and cancel