fix hanging if