minor refactor with comments