Second half of generate method