refactore a little more