slightly improved method