Added some additional state conditionals to avoid inadvertently filtering a model that wasn't set.