implemented updateweights