Port the cardinality function to the place where it belongs (Model) and make it way lighter for the server