iOS: code refactoring