Additional type check, throwing exception.
Added type checking, throwing exceptions.