switch from java to scala