removed sonar violations
reduced code duplications
did some refactorings and reduced code duplications