refactor submission logic to common function