Add a constructive funtion, fix sonar issue.