some more refactoring from code review comments