convert match to if let
pass slice around instead of immutable array