update: optimize code