This should be wrapped in an if statement. The lines following assume that you matched it correctly which isn't a safe assumption.