refectored memory block allocation