Improve #8 Shell solution