implemented rect_index