implemented optimize functions for binary relations