removed $link from the insert function since it's no longer needed