functional, except for handling KeyErrors