better generation (version 2)