refactored linkHandler