converted to scala