consolidating javascript