added loop flag