refactor some utils