tfactory functional and optimized