removed unnecessary while(true) loop

fixed stack error