Changed some code to get it possible to implement in Java