Migrate to function for handling links on each page load