I gang

Port Java code to Scala