Converted from smail to java