simpler java version