First version of generate (not working at all)