Improved the if statements checking if the key is active and the link is present