code review and improvements