An answer, but not really the Scala way...