adding callback code and some state