Some functions for the generator