avoiding next statements
Merge pull request #12892 from akshay-vishnoi/refactor

avoiding next statements