Added cal_img func