updated submit function code