Refactor ex2-6.c