pseudo code there getting infinite loop