Refactoring: Replace Temp with Query 2