Modify code to catch exception thrown by invalid beacon