Update main.c

Added new function. 
Added network exit