finish Submit function