moved main code to its own function to please pylint