Queries 5 and 7 + Test Cases