Added check to not save empty batch