implemented changes suggested by pycharm code inspection