Add callbacks funtionality.

add for #20

Let me know what you think about it.