restored segfaulting code