Refactor to accept niter as an argument