changed query to work with test cases