Simplify logic in "tm_script.rb"