moved threshold check