Generalize handling of x/y index