bug fixes: issue #2 and issue #4