Make allocation dynamic to save on stack usage