fixed bug in backward search