new version of code with trace command support