change to simplier solution of 2 indexes