improve python a little code