Fixed PMD warning + bug revealed by PMD warning