A scheme within density functional theory is proposed that provides a practical way to generalize to unrestricted geometries the method applied with some success to layered geometries [H. Rydberg, et al., Phys. Rev. Lett. 91, 126402 (2003)]. It includes van der Waals forces in a seamless fashion. By expansion to second order in a carefully chosen quantity contained in the long range part of the correlation functional, the nonlocal correlations are expressed in terms of a density-density interaction formula. It contains a relatively simple parametrized kernel, with parameters determined by the local density and its gradient. The proposed functional is applied to rare gas and benzene dimers, where it is shown to give a realistic description.