fixed code structure in xcode