refactor by sonar