refactor the element resize