fix indefinitely waiting