shell.cpp major code reduction