Small adjustment to java solution