fix the bug mentioned in #317