update code following comments