rewrite patch for bug 15763, as requested