Adapting js to new markup structure