Updated to handle variable regions.