fix a coredump bug and add some prints