Quick bug fix for issue #256

Just a quick bug fix for issue #256.

There should be a better implementation out there, but we will keep this one while we don't have anything better.