new layout and reference logic added