move functions for handling links to a separate module