link creation logic