fix bugs. read dictionary only once