added explicit type declarations in the (case when then else end) statements