Remove unnecessary code from generate method