finished learn function