Taking vitamin D could help prevent dementia, study finds