replace raw pointer with reference