code cleanup and added link add idempotent-ness