finish the analysis and tidy the pseudocode