improve check on thread return