change of the last nested if, change of the comparison for the  element