changed some loops to faster map/fold/filter versions