implement learning, this still needs testing