refactor code: use utility