New scala code