refactor for js query