removed $first_loop flag