Fix math problem on wait for condition