tidy up if else block replace with Option.orElse
append to global wiring state