rewrite as shell script