added custom switch and db code