fixed the memomry leakage error. Just need to fix the uninitalized read and the program will be fine memory wise