Scala coursera assignment code