fixed recursive function
finished recursive search