refactored code for adding users to batch