trying to reorder javascript