minor bug fix to use MAX_CALLBACKS in loops