add moving callback function, and optimize code