Reduce complexity of shell function