implementation in Java