Running complete 'while' cycle and updating baum's algorithm