memory allocation issue #6 fix