applied old patch from commit 6f18ed7