minor JS restructuring