Michae's Java code