converted patch supplied by Ingo Hoffmann to pull request