Add more validations to avoid notices and warnings