Algorithm for Phase two updated