lp-function improved; not working right