refactoring js apis