Amended with new code

This is the new database code