dang refactor code