fixed bugs with cancel and submit