fixed bug with wrong indexes in result