fixed bug, added code to grab links, code tidying