put category link functionality into a function