fix for issue #23 (need more testing)