removed code duplication for layout