Refactory to support logical engine