Fixed select

Didn't actually use the index before.
Not tested yet though