Allocate the memory outside of the loop