Changed query

Did a bit of cleaning on the code to make it closer to an appropriate
version of what I want to happen