Add additional error check in extract.c