added break handling to main