clean up and better queries