Revert "Revert "fixes #40""

This reverts commit f64c36536bb6756290c6f2e58c59438a886dd915.