Bug fix by Xian-Guo