resolved double free() issue, output is not very reliable.