make query5 implementation suck less