sonar fixed some code duplication