A little code refactoring