Added apply function