Code refactor using PEP 8 best practices