optim pay function