added waiting in while true