added better error messages for invalid arguments.