Split some of the logic up in pieces