added infinite loop to run the queries