seems like you're missing an else here.  If you haven't found either A or B, then don't you want to error or return or something?