Shell Script Optimization