Fixing Issue #6. Needs testing