Added mapped task function to handle tasks in batches.