Refactored to improve pylint score.