pmd: remove unnecessary return and consolidate if statements