writing main