fixed some sonar violations
fixed null check