moving logic out of operator/mod.rs