fixing bugs introduced by previous merge of pull request #9