add glmain to simplify the main routine