fixed having KeyError where it should have been IndexError