use generator properly