implemented optimize functions for binary operations