convert if to switch (more than 3 nested ifs) closes #39