incorporating kyle's suggestions, and replace shell stuff