fix queries and optimize
clean up