Moved from shell script to Python script