Switched to Scala for the implementation