Fixed bug on weight matrix