refacto the shell code