This same block of code (lines 183-192) is in addPass, containsPass, and replacePass. Recommend moving this to a helper method called 'passFromArgs' or something that returns a PKPass object. You can check for nil in order to return early from each method that calls it.