updated im_temden code