I advise to make it a hash than array to remove repetition of same links (prevent deadlock).