Main with loop support