addded break condition for while true loop