updated main.c and corrected a small bug