finshed cleanup, added nonlinear routine