break up the logic