Reducing panels.panel index and length comparison