fixed ref error on internal function