Simplify code for finding subplot index