Converted the template to Java