Updated Code for Database