Better if-then-else and reorganize