completed Query5
fixed minor bug