simplified some loop stuff