replace cartesian expressions to improve perfomance