use patterns in scala way