Prevent calling method on undefined