New main handeling applied to template and test program