Lab3.scala final revision