change some java to scala