begin major refactor of js