Added a crappy Scala implementation