code refactoring for Xcode