take tm function out. belongs in a script