Refactoring setup code