add callbacks, fix sum bugs