started using Optim. Not working so far