changed an `if` to a `case`
fixed type specs