Sample code refactoring