Finally fixing thread query