Updated the code for Database based on codereview feedback