Adjusted the query at some points to make it more lightweight
Some testing work