split DB manipulation into seperate file. Also normalized the database.