update main code to support layout changes