Split handling of SUBMIT packet into a function