Preliminary update function done (may be broken as fuck)