improving python scripts