implemented the learn function