This check and the previous one can be unified and the exception message can be more inclusive