Refactor the code to handle some of pylint issues