fixed logic in mapping thread