implementation of fix for #4. no tests yet.