Rewrote layout drawing to remove code duplicate