added break statements in main if-then code