divide into functions (nw)