Initial implementation of the joint term of the joint optimization