fix uninitialized memory error found by valgrind