fixed a bug in find function