Patterns in scala