load cmd
small refactoring
fix some bugs in substitutions