added type checking for mesh elements