Added more pseudo code.