fixed better error handling in linkedlist.c