reducing memory allocating