Reordered case statements and added comments