Fix issue with shape generation function