fixed some bugs in allocating