fixed declare residency bugs