hw6 elaborated - need to fix the key error