Fixed bug with updating database