Preallocating memory to avoid duplication