Fixing code after Pycharms Code Inspection