fixed problems described in issue #1 and issue #2