As above, reduce boiler-plate, by selecting the function in the `if...else...` block and calling it outside.