Fixed to deal with cases of zero or one match