Fix the beforeOpen callback check