adding .py implementation, little tweak in .java