fixed #33. improve batch assignment