refactoring to fix sonar problems