adding apply function