Changed the generate method to regenerate