a little code refactoring