Fix for prevIdx going < 0

Fixes #211