enhanced the parseLinks function