Added comments to code

Also renamed the update function