Why do you `pop` from kw rather than just `get` from it? kw is not used anywhere else so the extra delete is meaningless.