A method for nonsmooth optimization problems