refactor and dry code