Refactoring stage 1, links
Refactoring code