fixed the pointers alive across function calls