modifying generate method