issue #789, incorrect res index calling fixed. Tested on my machine and this commit is working correctly, at least for my test dataset