Avoid allocating unnecessary memory on the stack