fixed error causing segfault