factored existing ref macro into seperate file.