for performance reasons, you should re-write this as an if statement. Match statements are expensive in scala.