refactoring on Perceptron class