added a check for index out of range error for uv generation