Improved Code according to SonarQube report