some cleanup refactoring