Small re-factorization 

Edited the code to confine to some java rules and to clean the code up.