NN: better definition of cost function indicies