modified for better alloc