Refactor query interface controller part