Refactoring UP code