utils: put some common code into 'utils'