changed some logic in updating