Add the boolean function

also made some changes to procedure to cut down on global variable
use... seemed sloppy.