minor optimization in proto.use function

i switched the order of function validation and route defaulting so function validation is first. i figured it makes more sense to throw an error first than to assign a faulty function to a default route, then check if function is valid.