generation algorithm improvements