Update the two funcions with new code