Use six.moves.range for Python 3 compatibility