consolidate layout function and account for updates to width/height.