Implemented learning algorithm