added function for conditional expectation