Tal's Java code