Fixed Valgrind Error: reading from unallocated