update code based on pr #6 review