Refactored code and improve code quality based on Sonar