Added Error Checking for dictionary