refactoring to fitt sonar and to clean code