fix allocation loop termination
Merge pull request #105 from tzik/allocation_loop

fix allocation loop termination