continued refactoring js