Fix for Issue #41 - seems to succeed the test cases, but fix might not be generic