more optim

R-tested - still working