fixed a tricky bug in finding labels