Fix PEP8 errors and removed loop running forever