Fixed state events listeners and now looping the queries