wrote get n function