Better way of testing result of getElementById