implemented a better layout function and worked on the imagegeneration.