updated functions for xcode/swift update
refactored callback to account for optionals and nil response