getLinks changed to reduce redundant code