replaced Temp with Query