implemented in Java