Small changes in add_if function