more fleshed out python script