some changes from latest pull request