implements findBy function