updated ex6.c