fix bug in limit detection