memory leak free, and fixed invalid read on initialization check
Insert and free cin/cout/endl if iostream and THEN std namespace