move error reporting into its own method
move payload validation to a helper method