fixed seg fault bug.