implemented some of the pattern recog stuff