fixed scala code