refactor tanx