Added conditions to handle batch operations.