Ref refactor