Why use temporary variable activeUsers? Why not append the filter in the if branch? Also, you could merge the two ifs into one: "if QUser.inactive in q and AsBoolean.value in q.inactive"