Added check for dictionary length.