Fix key error produced where dictionary True and False values are counted