Abstracted out some code from update into their own functions.