I think this function can just return a list of expressions (similar to how it was before it was a function). I don't see a reason to have to assign booleans to these two variables.