ported to REScala after the restructuring