added a learning algorithm