Fully implements update function