change signature to pattern matching