moved visitor function between if statements. added comments