bugfix from Weizhu Chen