What would be the gain, if we do rewrite this code using case..when ? I don't think we can do it in a fewer lines of code, than the nested if.