Attempted to add error handling with setjmp/longjmp
Currently segfaults and goes to wrong function upon longjmp