refactor the code
add ipdb