added row or col < 0 check to get_index to cover the edge cases so now everything works as expected