java and scala implementation more similar