Use Hash#[] instead of Hash#has_key?

Because we need to check value as well as key.