fix indices and clean up data selection