moving logic out of view