Extract some utility functions