Modified logic to not run query twice and added a baseline test case