cleaned up loop in main