Better test for stop condition