First java version of the python script. Dirty.