guard against inifinte loops