optimize link logic