based on the patch in #35