updated batch processing logic, still needs work.