Tidying up undefined checks