fork from https://github.com/nicolasgramlich