Cleaned up generate() by creating a separate function for handling
each cell