reflected changes after code review
includes function declaration/definition reordering