fixing up broken pseudo code