implements learn function