finished main code template