First attempt at fixing issue #15 (UNTESTED)