reorganized callback functions