updated database code