now we are at the most complex code with the least duplication