rename variable; free memory before returning