update main code for updatePen