modified ex4.c