updated function to change the DOM

need to added comments and do one last test