null thread check added