Updated code using suggestions from pylint