an example refactoring to cleaner code