Move all logic to one place.