fix js random index bounds