Fixed mem_alloc issue