helper function for submit which avoid casting