fix threshold comparison