complex mathcing logic wip