tidied up the js with some nudges and combining the lines.