Fixed issue #1 segmentation fault