implemented -json and -index options