fixed sonar code violations
if statement simplifications and code duplications