swaps if-else logic to make it more readable