Make anchor code more generic