separate out parameter validation into helper