updated generate method