Add last condition for ev function
Remove shadowing variables