edited getElementAttribute so that it is much more readable