better allocation of memory, make sure to free other memory