replace case..when with Classes