Script now properly updates database