Avoid passing boolean as a function parameter!
It makes your code harder to read.
It is also a sign that your function has multiple responsibilities, violating the Single Responsibility Principle.
It is better to split the logic, and leaving the decision to the caller.