updated codes from eric