fixed bug in allocation algorithm