Translating old script into java