Properly throw exception if types mismatch