Fix segmentation fault

This fix removes segmentation fault that was introduced because modifying the source code without understanding it properly.