refactored backpropagation, code is now significantly slower but functional