Added a check for batch size

Improvements to previous commit