generate method now working properly