started refactoring python script