search function more or less works