set a.href only when not already set

I also cleaned up the code a little. I can do a rebase if you'd like