refactored from initial ttt