Switched from messy nested ifs to case