added type checking