code reviewed and cleaned thanks to pycharm analysis