New algorithm for the optimization of geometries in local density functional theory