copied main.c from master branch