modified, following Yunzhi's suggestions.