clean up code whenever submit button is clicked