applyed various code fix thanks to pycharm inspector