fixed control flow and corrected some errors in list.c