Fixes #404

The idea is still the same. Execution is slightly different.