fixed non-exhaustive pattern match