These parameter type checking could probably be generalized to a helper method.

Would also make the error messages consistent.