User function can now return a value. Also an exception DispatchFailed is raised if a pattern cannot be found