seperate the main entry to main.c, monitoring related funcs put into monitor.c/monitor.h