code refactoring from sonar analysis.

This request include code refactoring from sonar analysis.