This is perhaps one of the most complex parts