Fix bug #79

Refactoring bug - needs a test