optimize code, update img