add learning logic

Signed-off-by: Fons <lord.fontana@gmail.com>