Reractor the logic