refactored js api