improve python script