Refactored as python script