#189 refactored query functionality from js to java