added comments and destryed temp_img to free memory