some minor code refactoring