fixing bugs from issue #7