added mode.c and mode.h