Modified the addDataToDictionary function to test for bad memory error