added check on number of codes passed