fixed pseudo code