separating out the conditions to handles different cases.