more refactoring of the old js