Found that the error is in the generate method