Add some checks before calling functions to support collections in addition to models.