edited as suggested from code review