Added more layout logic