Changed if block to case statements

Case statements are much easier to read, and execute faster
Replaced another IF block with case statements

Case statements made more sense, are less visual noise and execute
quicker
Large format update to conform to the reference module