The batch function implemented