Update main.c

add fail location and updates loop code