Helper functions for implementing the stat functions