javascript object reference hell