Redoing the mod in Scala