Factor out the codes that will be constantly reuse.