All this logic is repeated. It should be a new helper method in the processor