Sonar: removed duplicate code