Updated state query to execute just once