refactored the reference manager