Fixed error on function to generate links