Moved shell code to python