Fix function

Wrong function in apply(), switched to all()