fixing bug in callback code