refactored generateReferences