fixed look up of the number of variables