Applying DRY
Added payload max size check