refactor for more js vice java