Refactor from tsa