Code refactoring - shell.c