changed if/then to a match expression