Refactoring due to asynchronous query handling