Refactor payload handling out of the view