much more scala way using PartialFunction and case