Fixed a bug which caused a core dump