Reordered the CASE statement