fixed bug in discardLinks