Fixed a fatal error in some cases