added type checking.