before alloc function