Fixed a crash bug

A crash bug was added during refactoring: fixed.