Added difference threshold check