added most of query 5

still need to figure out how to break ties