optimized another query and updated a test case