fixed a printing error and segfault