refactoring the references module so it can be used like an api