add query & refactor