a bit of cleanup refactoring