Updated with comments and changed update method