iOS: code refactor