properly index result array