generator implementation